import javax.naming.PartialResultException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Stack;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lishuo
 * Date: 2023-05-13
 * Time: 18:52
 */
public class TestDemo1 {
    // 冒泡排序
    public static int[] bubbleSort(int[] array) {
        for (int i = 0; i < array.length-1; i++) {
            boolean flag = false;
            for (int j = 0; j < array.length-1-i; j++) {
                if (array[j]>array[j+1]) {
                    flag = true;
                    int tmp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = tmp;
                }
                if (!flag) {
                    break;
                }
            }
        }
        return array;
    }

    // 暴力排序
    public static int[] violentSort(int[] array) {
        for (int i = 0; i < array.length-1; i++) {
            for (int j = i+1; j < array.length; j++) {
                if (array[i]>array[j]) {
                    int tmp = array[i];
                    array[i] = array[j];
                    array[j] = tmp;
                }
            }
        }
        return array;
    }

    public static void main(String[] args) {
        int[] array = {9,8,7,6,5,4,3,2,1,0};
        array = violentSort(array);
        System.out.println(Arrays.toString(array));
        

    }
}
